package com.nsgf.library.data.bean;

import java.util.List;

public class WaterInfoListBean {

    private List<ReservoirBean> reservoir;
    private List<FlowBean> flow;
    
    // 新的API结构字段
    private String projectCode;
    private String projectCodeDesc;
    private String facilityCode;
    private String projectName;
    private String facilityName;
    private Double rz;  // 水位
    private String tm;  // 时间
    private List<WaterInfoListBean> children;  // 子节点（设施列表）
    private Double floodLimitLevel;  // 汛限水位
    private String facilityType;  // 设施类型

    public List<ReservoirBean> getReservoir() {
        return reservoir;
    }

    public void setReservoir(List<ReservoirBean> reservoir) {
        this.reservoir = reservoir;
    }

    public List<FlowBean> getFlow() {
        return flow;
    }

    public void setFlow(List<FlowBean> flow) {
        this.flow = flow;
    }
    
    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }

    public String getProjectCodeDesc() {
        return projectCodeDesc;
    }

    public void setProjectCodeDesc(String projectCodeDesc) {
        this.projectCodeDesc = projectCodeDesc;
    }

    public String getFacilityCode() {
        return facilityCode;
    }

    public void setFacilityCode(String facilityCode) {
        this.facilityCode = facilityCode;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getFacilityName() {
        return facilityName;
    }

    public void setFacilityName(String facilityName) {
        this.facilityName = facilityName;
    }

    public Double getRz() {
        return rz;
    }

    public void setRz(Double rz) {
        this.rz = rz;
    }

    public String getTm() {
        return tm;
    }

    public void setTm(String tm) {
        this.tm = tm;
    }

    public List<WaterInfoListBean> getChildren() {
        return children;
    }

    public void setChildren(List<WaterInfoListBean> children) {
        this.children = children;
    }

    public Double getFloodLimitLevel() {
        return floodLimitLevel;
    }

    public void setFloodLimitLevel(Double floodLimitLevel) {
        this.floodLimitLevel = floodLimitLevel;
    }

    public String getFacilityType() {
        return facilityType;
    }

    public void setFacilityType(String facilityType) {
        this.facilityType = facilityType;
    }
    
    // 格式化方法用于数据绑定
    public String getRzFormatted() {
        if (rz == null) {
            return "--m";
        }
        return String.format("%.2fm", rz);
    }
    
    public String getFloodLimitLevelFormatted() {
        if (floodLimitLevel == null) {
            return "";
        }
        return "汛限水位:" + String.format("%.1fm", floodLimitLevel);
    }
    
    // 判断是否为项目节点（有projectCodeDesc且children不为空）
    public boolean isProjectNode() {
        return projectCodeDesc != null && children != null && !children.isEmpty();
    }
    
    // 判断是否为设施节点（有facilityName）
    public boolean isFacilityNode() {
        return facilityName != null;
    }
    
    // 格式化项目标题（如果需要，可以在这里处理格式）
    public String getProjectTitle() {
        if (projectCodeDesc == null) {
            return "";
        }
        // 如果项目名称已经包含"水位"，直接返回；否则可以添加
        if (projectCodeDesc.contains("水位")) {
            return projectCodeDesc;
        }
        // 根据实际需求，可能需要格式化，暂时直接返回
        return projectCodeDesc;
    }
    
    // 格式化设施名称（提取关键部分，如"大闸内湖水文站" -> "大闸内湖水位"）
    public String getFacilityDisplayName() {
        if (facilityName == null) {
            return "";
        }
        // 如果名称包含"水文站"，替换为"水位"
        if (facilityName.contains("水文站")) {
            return facilityName.replace("水文站", "水位");
        }
        return facilityName;
    }

    public static class ReservoirBean {
        /**
         * id : null
         * facilityCode : 4211821004
         * areaCode : 421182100000
         * facilityType : water.obj.type.8
         * facilityTypeDesc : 水位站
         * facilityName : 坝前水位站(梅川)
         * pictureUrl : /facility/1752799945753.jpg
         * location : null
         * remark : 梅川水库坝前水雨情站，位于梅川水库主坝前，高程61.539m，监测雨量、水位、图像，翻斗式、气泡式。
         * createTime : 2025-05-23T10:09:58
         * createBy : null
         * updateTime : 2025-10-05T20:12:48
         * updateBy : null
         * status : 1
         * sort : 1
         * area : null
         * statusBl : true
         * buildType : null
         * files : null
         * diagramFiles : null
         * responsiblePerson : null
         * coordinates : 115.62165,30.154016
         * contactNumber : null
         * designDiagram : null
         * listEquipmentRt : null
         * listWtObjRt : null
         * videoUrl : null
         * videoFiles : null
         * videoList : null
         * stationType : water.level.station.type.5
         * stationTypeDesc : 水库水位站
         * content : null
         * river : null
         * basinWaterSystem : null
         * stationDate : 2025-05-01
         * source : water.level.source.1
         * sourceDesc : 自建
         * guikouMagDepartment : null
         * waterType : 0
         * floodWaterLevel : 65.56
         * waterLevel : 68.5
         * floodWaterLevelTime : 2025-10-24 10:55:00
         * chargeName : null
         * trafficType : null
         * projectCode : null
         * pointX : null
         * pointY : null
         */

        private Object id;
        private String facilityCode;
        private String areaCode;
        private String facilityType;
        private String facilityTypeDesc;
        private String facilityName;
        private String pictureUrl;
        private Object location;
        private String remark;
        private String createTime;
        private Object createBy;
        private String updateTime;
        private Object updateBy;
        private int status;
        private int sort;
        private Object area;
        private boolean statusBl;
        private Object buildType;
        private Object files;
        private Object diagramFiles;
        private Object responsiblePerson;
        private String coordinates;
        private Object contactNumber;
        private Object designDiagram;
        private Object listEquipmentRt;
        private Object listWtObjRt;
        private Object videoUrl;
        private Object videoFiles;
        private Object videoList;
        private String stationType;
        private String stationTypeDesc;
        private Object content;
        private Object river;
        private Object basinWaterSystem;
        private String stationDate;
        private String source;
        private String sourceDesc;
        private Object guikouMagDepartment;
        private int waterType;
        private String floodWaterLevel;
        private double waterLevel;
        private String floodWaterLevelTime;
        private Object chargeName;
        private Object trafficType;
        private Object projectCode;
        private Object pointX;
        private Object pointY;

        public Object getId() {
            return id;
        }

        public void setId(Object id) {
            this.id = id;
        }

        public String getFacilityCode() {
            return facilityCode;
        }

        public void setFacilityCode(String facilityCode) {
            this.facilityCode = facilityCode;
        }

        public String getAreaCode() {
            return areaCode;
        }

        public void setAreaCode(String areaCode) {
            this.areaCode = areaCode;
        }

        public String getFacilityType() {
            return facilityType;
        }

        public void setFacilityType(String facilityType) {
            this.facilityType = facilityType;
        }

        public String getFacilityTypeDesc() {
            return facilityTypeDesc;
        }

        public void setFacilityTypeDesc(String facilityTypeDesc) {
            this.facilityTypeDesc = facilityTypeDesc;
        }

        public String getFacilityName() {
            return facilityName;
        }

        public void setFacilityName(String facilityName) {
            this.facilityName = facilityName;
        }

        public String getPictureUrl() {
            return pictureUrl;
        }

        public void setPictureUrl(String pictureUrl) {
            this.pictureUrl = pictureUrl;
        }

        public Object getLocation() {
            return location;
        }

        public void setLocation(Object location) {
            this.location = location;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getCreateTime() {
            return createTime;
        }

        public void setCreateTime(String createTime) {
            this.createTime = createTime;
        }

        public Object getCreateBy() {
            return createBy;
        }

        public void setCreateBy(Object createBy) {
            this.createBy = createBy;
        }

        public String getUpdateTime() {
            return updateTime;
        }

        public void setUpdateTime(String updateTime) {
            this.updateTime = updateTime;
        }

        public Object getUpdateBy() {
            return updateBy;
        }

        public void setUpdateBy(Object updateBy) {
            this.updateBy = updateBy;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public int getSort() {
            return sort;
        }

        public void setSort(int sort) {
            this.sort = sort;
        }

        public Object getArea() {
            return area;
        }

        public void setArea(Object area) {
            this.area = area;
        }

        public boolean isStatusBl() {
            return statusBl;
        }

        public void setStatusBl(boolean statusBl) {
            this.statusBl = statusBl;
        }

        public Object getBuildType() {
            return buildType;
        }

        public void setBuildType(Object buildType) {
            this.buildType = buildType;
        }

        public Object getFiles() {
            return files;
        }

        public void setFiles(Object files) {
            this.files = files;
        }

        public Object getDiagramFiles() {
            return diagramFiles;
        }

        public void setDiagramFiles(Object diagramFiles) {
            this.diagramFiles = diagramFiles;
        }

        public Object getResponsiblePerson() {
            return responsiblePerson;
        }

        public void setResponsiblePerson(Object responsiblePerson) {
            this.responsiblePerson = responsiblePerson;
        }

        public String getCoordinates() {
            return coordinates;
        }

        public void setCoordinates(String coordinates) {
            this.coordinates = coordinates;
        }

        public Object getContactNumber() {
            return contactNumber;
        }

        public void setContactNumber(Object contactNumber) {
            this.contactNumber = contactNumber;
        }

        public Object getDesignDiagram() {
            return designDiagram;
        }

        public void setDesignDiagram(Object designDiagram) {
            this.designDiagram = designDiagram;
        }

        public Object getListEquipmentRt() {
            return listEquipmentRt;
        }

        public void setListEquipmentRt(Object listEquipmentRt) {
            this.listEquipmentRt = listEquipmentRt;
        }

        public Object getListWtObjRt() {
            return listWtObjRt;
        }

        public void setListWtObjRt(Object listWtObjRt) {
            this.listWtObjRt = listWtObjRt;
        }

        public Object getVideoUrl() {
            return videoUrl;
        }

        public void setVideoUrl(Object videoUrl) {
            this.videoUrl = videoUrl;
        }

        public Object getVideoFiles() {
            return videoFiles;
        }

        public void setVideoFiles(Object videoFiles) {
            this.videoFiles = videoFiles;
        }

        public Object getVideoList() {
            return videoList;
        }

        public void setVideoList(Object videoList) {
            this.videoList = videoList;
        }

        public String getStationType() {
            return stationType;
        }

        public void setStationType(String stationType) {
            this.stationType = stationType;
        }

        public String getStationTypeDesc() {
            return stationTypeDesc;
        }

        public void setStationTypeDesc(String stationTypeDesc) {
            this.stationTypeDesc = stationTypeDesc;
        }

        public Object getContent() {
            return content;
        }

        public void setContent(Object content) {
            this.content = content;
        }

        public Object getRiver() {
            return river;
        }

        public void setRiver(Object river) {
            this.river = river;
        }

        public Object getBasinWaterSystem() {
            return basinWaterSystem;
        }

        public void setBasinWaterSystem(Object basinWaterSystem) {
            this.basinWaterSystem = basinWaterSystem;
        }

        public String getStationDate() {
            return stationDate;
        }

        public void setStationDate(String stationDate) {
            this.stationDate = stationDate;
        }

        public String getSource() {
            return source;
        }

        public void setSource(String source) {
            this.source = source;
        }

        public String getSourceDesc() {
            return sourceDesc;
        }

        public void setSourceDesc(String sourceDesc) {
            this.sourceDesc = sourceDesc;
        }

        public Object getGuikouMagDepartment() {
            return guikouMagDepartment;
        }

        public void setGuikouMagDepartment(Object guikouMagDepartment) {
            this.guikouMagDepartment = guikouMagDepartment;
        }

        public int getWaterType() {
            return waterType;
        }

        public void setWaterType(int waterType) {
            this.waterType = waterType;
        }

        public String getFloodWaterLevel() {
            return floodWaterLevel;
        }

        public void setFloodWaterLevel(String floodWaterLevel) {
            this.floodWaterLevel = floodWaterLevel;
        }

        public double getWaterLevel() {
            return waterLevel;
        }

        public void setWaterLevel(double waterLevel) {
            this.waterLevel = waterLevel;
        }

        public String getFloodWaterLevelTime() {
            return floodWaterLevelTime;
        }

        public void setFloodWaterLevelTime(String floodWaterLevelTime) {
            this.floodWaterLevelTime = floodWaterLevelTime;
        }

        public Object getChargeName() {
            return chargeName;
        }

        public void setChargeName(Object chargeName) {
            this.chargeName = chargeName;
        }

        public Object getTrafficType() {
            return trafficType;
        }

        public void setTrafficType(Object trafficType) {
            this.trafficType = trafficType;
        }

        public Object getProjectCode() {
            return projectCode;
        }

        public void setProjectCode(Object projectCode) {
            this.projectCode = projectCode;
        }

        public Object getPointX() {
            return pointX;
        }

        public void setPointX(Object pointX) {
            this.pointX = pointX;
        }

        public Object getPointY() {
            return pointY;
        }

        public void setPointY(Object pointY) {
            this.pointY = pointY;
        }
        
        // 格式化方法用于数据绑定
        public String getFloodWaterLevelFormatted() {
            return floodWaterLevel + "m";
        }
        
        public String getWaterLevelText() {
            return "汛限水位:" + waterLevel + "m";
        }
        
        // 判断当前水位是否超过汛限水位
        public boolean isWaterLevelOverLimit() {
            try {
                double currentLevel = Double.parseDouble(floodWaterLevel);
                return currentLevel > waterLevel;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    }

    public static class FlowBean {
        /**
         * list : null
         * id : 1914874366733897212
         * facilityCode : 4211821204
         * projectId : null
         * tm : 2025-10-24 10:55:00
         * rz : null
         * inq : 0.499
         * w : null
         * blrz : null
         * otq : null
         * rwchrcd : null
         * rwptn : null
         * inqdr : null
         * msqmt : null
         * name : null
         * projectName : null
         * tmUnit : null
         * trafficType : 1
         * facilityName : 生态流量站(梅川)
         */

        private Object list;
        private long id;
        private String facilityCode;
        private Object projectId;
        private String tm;
        private Object rz;
        private double inq;
        private Object w;
        private Object blrz;
        private Object otq;
        private Object rwchrcd;
        private Object rwptn;
        private Object inqdr;
        private Object msqmt;
        private Object name;
        private Object projectName;
        private Object tmUnit;
        private int trafficType;
        private String facilityName;

        public Object getList() {
            return list;
        }

        public void setList(Object list) {
            this.list = list;
        }

        public long getId() {
            return id;
        }

        public void setId(long id) {
            this.id = id;
        }

        public String getFacilityCode() {
            return facilityCode;
        }

        public void setFacilityCode(String facilityCode) {
            this.facilityCode = facilityCode;
        }

        public Object getProjectId() {
            return projectId;
        }

        public void setProjectId(Object projectId) {
            this.projectId = projectId;
        }

        public String getTm() {
            return tm;
        }

        public void setTm(String tm) {
            this.tm = tm;
        }

        public Object getRz() {
            return rz;
        }

        public void setRz(Object rz) {
            this.rz = rz;
        }

        public double getInq() {
            return inq;
        }

        public void setInq(double inq) {
            this.inq = inq;
        }

        public Object getW() {
            return w;
        }

        public void setW(Object w) {
            this.w = w;
        }

        public Object getBlrz() {
            return blrz;
        }

        public void setBlrz(Object blrz) {
            this.blrz = blrz;
        }

        public Object getOtq() {
            return otq;
        }

        public void setOtq(Object otq) {
            this.otq = otq;
        }

        public Object getRwchrcd() {
            return rwchrcd;
        }

        public void setRwchrcd(Object rwchrcd) {
            this.rwchrcd = rwchrcd;
        }

        public Object getRwptn() {
            return rwptn;
        }

        public void setRwptn(Object rwptn) {
            this.rwptn = rwptn;
        }

        public Object getInqdr() {
            return inqdr;
        }

        public void setInqdr(Object inqdr) {
            this.inqdr = inqdr;
        }

        public Object getMsqmt() {
            return msqmt;
        }

        public void setMsqmt(Object msqmt) {
            this.msqmt = msqmt;
        }

        public Object getName() {
            return name;
        }

        public void setName(Object name) {
            this.name = name;
        }

        public Object getProjectName() {
            return projectName;
        }

        public void setProjectName(Object projectName) {
            this.projectName = projectName;
        }

        public Object getTmUnit() {
            return tmUnit;
        }

        public void setTmUnit(Object tmUnit) {
            this.tmUnit = tmUnit;
        }

        public int getTrafficType() {
            return trafficType;
        }

        public void setTrafficType(int trafficType) {
            this.trafficType = trafficType;
        }

        public String getFacilityName() {
            return facilityName;
        }

        public void setFacilityName(String facilityName) {
            this.facilityName = facilityName;
        }
        
        // 格式化方法用于数据绑定
        public String getInqFormatted() {
            return inq + "m³/s";
        }
        
        public String getTrafficTypeText() {
            return trafficType == 0 ? "入库" : "出库";
        }
    }
}
